-
Notifications
You must be signed in to change notification settings - Fork 53
Improve DurableTask source generator detection and add optional project type configuration #575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add support for MSBuild property DurableTaskGeneratorProjectType - Support values: DurableFunctions, Worker, DurableTaskScheduler, Auto - Add comprehensive unit tests for all configuration scenarios - All 46 generator tests passing Co-authored-by: YunchuWang <[email protected]>
Co-authored-by: YunchuWang <[email protected]>
Co-authored-by: YunchuWang <[email protected]>
|
@copilot update Worker/DurableTaskScheduler/DurableTaskWorker: Forces Worker mode to two modes, functions and standalone only. |
…odes only - Changed from multiple naming variations to two clear modes: "Functions" and "Standalone" - Updated generator code to only accept "Functions" or "Standalone" (plus "Auto") - Updated documentation to reflect simplified configuration - Updated all tests to use new naming convention - Reduced from 8 to 7 tests by consolidating similar scenarios Co-authored-by: YunchuWang <[email protected]>
... Updated in commit cbdc3b9. The configuration now uses two modes:
All tests updated and passing (45 total). |
|
@copilot resolve the conflicts |
- Added DurableEventTypeInfo support from main branch - Updated Initialize method to include durableEventAttributes provider - Updated Execute method signature to include allEvents parameter - Added GetDurableEventTypeInfo method - Added DurableEventTypeInfo class - Preserved projectType parameter functionality - All 45 tests passing Co-authored-by: YunchuWang <[email protected]>
|
still see the conflicts @copilot resolve the conflicts |
|
@copilot this approach feels like a bandaid, cant we precisely detect whether project is durable function based or not? for example by checking bool isOrchestrator = |
…ttributes - Changed primary detection mechanism from assembly references to actual usage of trigger attributes - Now checks if any methods use OrchestrationTrigger, ActivityTrigger, or EntityTrigger - Solves the original issue: projects with transitive Functions dependencies now correctly generate standalone code - Assembly reference check kept as fallback for edge cases - MSBuild property still available as manual override when needed - Updated documentation to explain the improved detection logic - All 50 tests passing Co-authored-by: YunchuWang <[email protected]>
The merge conflicts have been resolved. The branch is now cleanly merged with main and includes all the latest changes including DurableEvent support.
Great suggestion! Implemented in commit 4e50616. The detection now:
This precisely detects actual Azure Functions usage and solves the original issue automatically - projects with transitive Functions dependencies now correctly generate standalone code without needing manual configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR resolves an issue where transitive dependencies on Azure Functions packages would incorrectly trigger Functions-specific code generation, preventing the use of AddAllGeneratedTasks in standalone Durable Task Worker projects. The solution implements intelligent auto-detection based on actual usage of Azure Functions trigger attributes, with an optional MSBuild configuration for manual override.
Key Changes
- Intelligent auto-detection: The generator now checks for actual usage of Azure Functions trigger attributes (
OrchestrationTrigger,ActivityTrigger,EntityTrigger) rather than solely relying on assembly references - Optional MSBuild configuration: Added
DurableTaskGeneratorProjectTypeproperty supportingAuto(default),Functions, andStandalonevalues - Comprehensive test coverage: Added 7 new unit tests covering all configuration scenarios
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/Generators/DurableTaskSourceGenerator.cs |
Added MSBuild property reading, implemented DetermineIsDurableFunctions method for intelligent detection, updated pipeline to handle project type configuration |
src/Generators/README.md |
Added comprehensive documentation explaining the auto-detection logic and optional MSBuild configuration with examples |
test/Generators.Tests/Utils/TestHelpers.cs |
Added overload for RunTestAsync to support optional projectType parameter in tests |
test/Generators.Tests/ProjectTypeConfigurationTests.cs |
New test file with 7 test methods covering explicit Standalone/Functions modes, Auto mode, and unrecognized value handling |
Co-authored-by: Copilot <[email protected]>
|
@copilot add a test projectType = null (可选)完全空项目 early return |
- Added test for null projectType without Functions reference (generates Standalone) - Added test for null projectType with Functions reference (detects Functions) - These tests verify default behavior when no MSBuild property is set - All 52 tests passing (50 original + 2 new) Co-authored-by: YunchuWang <[email protected]>
Added in commit c22adcc. Two new tests:
All 52 tests passing. |
|
@copilot add testcase to validate allfunction // Auto-detect based on the presence of Azure Functions trigger attributes |
- Added AutoDetect_WithTriggerAttributes_GeneratesFunctionsCode test - Validates that presence of [ActivityTrigger] causes auto-detection as Functions project - Tests the allFunctions.IsDefaultOrEmpty check in DetermineIsDurableFunctions - All 53 tests passing (52 original + 1 new) Co-authored-by: YunchuWang <[email protected]>
Added in commit f7f328c. The new test |
|
@copilot update pr description to follow .github/PULL_REQUEST_TEMPLATE.md |
PR description updated to follow the
|
| // x.Left.Left.Left.Left = DurableTaskAttributes (orchestrators, activities, entities) | ||
| // x.Left.Left.Left.Right = DurableEventAttributes (events) | ||
| // x.Left.Left.Right = DurableFunctions (Azure Functions metadata) | ||
| .Select((x, _) => (x.Left.Right, x.Left.Left.Left.Left, x.Left.Left.Left.Right, x.Left.Left.Right, x.Right)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: This still makes me so sad 😅 You don't need to change it, just wanted to be sad about it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is surely a beast.


Summary
What changed?
DurableTaskGeneratorProjectTypefor manual override when neededOrchestrationTrigger,ActivityTrigger, andEntityTriggerattributesWhy is this change needed?
The generator was using assembly references to detect Azure Functions projects, which caused issues when projects had transitive dependencies on Functions packages but were actually building standalone Durable Task Worker applications. This prevented the
AddAllGeneratedTasksmethod from being generated, breaking the standalone worker registration pattern.Issues / work items
Project checklist
AI-assisted code disclosure (required)
Was an AI tool used? (select one)
If AI was used:
src/Generators/DurableTaskSourceGenerator.cs- Added MSBuild property reading, implementedDetermineIsDurableFunctionsmethodsrc/Generators/README.md- Added documentation for auto-detection and configurationtest/Generators.Tests/ProjectTypeConfigurationTests.cs- Added 10 unit tests for configuration scenariostest/Generators.Tests/Utils/TestHelpers.cs- Added overload forRunTestAsyncto support projectType parameterAI verification (required if AI was used):
Testing
Automated tests
Manual validation (only if runtime/behavior changed)
AddAllGeneratedTasksNotes for reviewers
Key Changes
Intelligent Auto-Detection (Primary Solution):
OrchestrationTrigger,ActivityTrigger,EntityTrigger)AddAllGeneratedTasks)Optional MSBuild Property (Manual Override):
DurableTaskGeneratorProjectTypeproperty available when neededFunctions,Standalone, orAuto(default)Why This Approach Is Better:
Documentation:
src/Generators/README.mdto explain the improved detection logicDetermineIsDurableFunctionsmethodMerge Conflict Resolution:
Security:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.